#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int n, m, tot;
int a[N];
char s[N];
int f[N << 1];
void init(int n) { rep(i, 1, n) f[i] = i; }
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
void merge(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx != fy) {
    if (fx < fy) swap(fx, fy);
    f[fy] = fx;
  }
}
int go(int pos, char c) {
  if (c == 'A')
    return pos + 1;
  else
    return find(pos + 1);
}
void solve() {
  cin >> n >> m;
  tot = m + n * 3;
  init(tot);
  rep(i, 1, n) cin >> s[i];
  set<int> black;
  rep(i, 1, m) {
    int x;
    cin >> x;
    black.insert(x);
    if (x < tot) merge(x, x + 1);
  }
  int pre = 1, now = 1;
  rep(i, 1, n) {
    // cout << i << ' ';
    rep(j, max(i - 1, 1), i) {
      char c = s[j];
      now = go(pre, c);
      // cout << pre << "->" << now << ' ';
      if (j != i) pre = now;
    }
    // cout << endl;
    merge(now, now + 1);
  }
  rep(i, 1, tot) if (f[i] != i) black.insert(i);
  cout << black.size() << endl;
  for (int x : black) cout << x << ' ';
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}